"use strict"
/**
 * @class  elFinder command "auth"
 * @author Silenus
 **/
elFinder.prototype.commands.auth = function() {
	var self  = this,
		fm    = self.fm,
		mimes = [];
	
	this.disableOnSearch = true;
	
	this.exec = function(hashes, type) {
		/* alert("auth execute!!!"); */
		var choice_pid =null;
//		var bind = $('#dialogPrivilege').bind('p_choice',function(e,pid,text,target){console.log(arguments)});
		$('#dialogPrivilege').dialog({
			modal	:	true,
			close	:	function (){$(this).dialog( "destroy" );},
			buttons	:	{
				'ok'	:	function(){
					var pid = $('#dialogPrivilege span.selected').attr('pid');
					console.log(pid);
					console.log(fm.selected());
					if ( 'undefined' == typeof pid ){
						return false ;	
					}else{
						$.ajax({
							type:'POST',
							success:function (){
								alert('提交成功');
							}
						});
					}
				},
				'cancel'	:	function (){$(this).dialog( "destroy" );}
			},
		});
	}

	this.getstate = function(sel) {
		var sel = this.files(sel),
			cnt = sel.length;
		return sel.length == 1 && sel[0].read && sel[0].write && sel[0].mime.indexOf('directory') !== -1 ? 0 : -1;
	}
}